package com.soft.javase.ch04.duotai;

/**
 * @author wangzhisen
 * @Desc TODO
 * @date 2025/4/22
 *
 * 多态：
 * 1.对外表现是一种形态，内在是有多种实现
 * 2.典型情况
 * 2.1 方法重载
 * 2.2 方法重写
 * 2.3 父类的引用指向子类的实例
 * 2.4 多态参数：方法的形参是父类类型，实际传递的是子类类型
 */
public class Animal {
    private String name;
    private String color;
    private int age;

    public void eat(Animal a) {
        System.out.println(name+"正在吃东西呢");
    }

    public static void play(){
        System.out.println("正在吃东西");
    }

    public Animal() {
    }

    public Animal(String name, String color, int age) {
        this.name = name;
        this.color = color;
        this.age = age;
    }


    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取
     * @return color
     */
    public String getColor() {
        return color;
    }

    /**
     * 设置
     * @param color
     */
    public void setColor(String color) {
        this.color = color;
    }

    /**
     * 获取
     * @return age
     */
    public int getAge() {
        return age;
    }

    /**
     * 设置
     * @param age
     */
    public void setAge(int age) {
        this.age = age;
    }

    public String toString() {
        return "Animal{name = " + name + ", color = " + color + ", age = " + age + "}";
    }
}
